package com.zhangfei.config;

import lombok.Getter;
import org.springframework.util.ObjectUtils;

/**
 * 序列号的前缀
 */
@Getter
public enum SerialTagEnum {
    SIT("SIT", "SIT测试模板"),
    PRE("PRE", "PRE测试模板"),
    PROD("PROD", "PROD测试模板"),
    ;


    private final String code;

    private final String value;


    SerialTagEnum(String code, String value) {
        this.code = code;
        this.value = value;
    }

    /**
     * 通过value取枚举
     *
     * @param code
     * @return
     */
    public static SerialTagEnum getEnumByValue(String code) {
        if (ObjectUtils.isEmpty(code)) {
            return null;
        }
        for (SerialTagEnum enums : SerialTagEnum.values()) {
            if (enums.getCode().equals(code)) {
                return enums;
            }
        }
        return null;
    }
}
